<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <cpn :c-info="info" :child-my-message="message"></cpn>
  </div>

  <template id="cpn">
    <!-- 只能有一个根节点!!!!!!!!!!!!!!!!! -->
    <!-- 子组件有很多的标签的时候,必须包含一个根 -->
    <div>
      <h2>{{cInfo}}</h2>
      <h3>{{childMyMessage}}</h3>
    </div>
  </template>

  <script>
    const cpn = {
      template: '#cpn',
      props: {
        // 驼峰写法注意!!! 这里驼峰 v-bind绑定就必须 c-info, 但是引用的时候还是cInfo
        cInfo: {
          type: Object,
          // 对象数组必须是函数返回
          default () {
            return {}
          }
        },
        childMyMessage: {
          type: String,
          default: '没传过来'
        }
      }
    }

    var vm = new Vue({
      el: '#app',
      data: {
        info: {
          name: 'why',
          age: 18,
          height: 1.88
        },
        message: '来了老弟'
      },
      methods: {},
      components: {
        cpn
      }
    });
  </script>
</body>

</html>